package com.itheima.tlias84.config;

import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import jakarta.annotation.Resource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 使用@Bean注解， 自动装配阿里云oss对象 实现阿里云链接对象的复用
 */
@Configuration
public class LoadOssConfig {

    @Resource
    AliyunOssConfig ossConfig;

    @Bean("ossBean")
    public OSS createOss(){
        return new OSSClientBuilder().build(ossConfig.getEndpoint(), ossConfig.getAccessKeyId(),
                ossConfig.getSecretAccessKey());
    }

}
